<template>
    <div>
        <el-form   :model="model" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
            <el-row>
            <el-col :span="8">    
            <el-form-item label="员工编号" prop="PersonCode">
                <el-input v-model="model.PersonCode"></el-input>
            </el-form-item>
            </el-col>

            <el-col :span="8">    
            <el-form-item label="员工姓名" prop="Name">
                <el-input v-model="model.Name"></el-input>
            </el-form-item>
            </el-col>

            <el-col :span="8">    
            <el-form-item label="员工性别" prop="Sex">
                <el-input v-model="model.Sex"></el-input>
            </el-form-item>
            </el-col>
            </el-row>

            <el-row>
            <el-col :span="8">   
            <el-form-item label="出生日期" prop="Birthday">
                <el-date-picker type="date" placeholder="选择日期" v-model="model.Birthday" style="width: 100%;"></el-date-picker>
            </el-form-item>
            </el-col>


            <el-col :span="8">   
            <el-form-item label="民族" prop="Nation">
                <el-input v-model="model.Nation"></el-input>
            </el-form-item>
            </el-col>

            <el-col :span="8">   
            <el-form-item label="政治面貌" prop="Political">
                <el-input v-model="model.Political"></el-input>
            </el-form-item>
            </el-col>
            </el-row>

            <el-row>
            <el-col :span="8">
            <el-form-item label="籍贯" prop="NativePlace">
                <el-input v-model="model.NativePlace"></el-input>
            </el-form-item>
            </el-col>

            <el-col :span="8">
            <el-form-item label="身高" prop="Height">
                <el-input v-model="model.Height"></el-input>
            </el-form-item>
            </el-col>

            <el-col :span="8">
            <el-form-item label="体重" prop="Weight">
                <el-input v-model="model.Weight"></el-input>
            </el-form-item>
            </el-col>
            </el-row>


            <el-row>
            <el-col :span="8">
            <el-form-item label="健康情况" prop="Health">
                <el-input v-model="model.Health"></el-input>
            </el-form-item>
            </el-col>

            <el-col :span="8">
            <el-form-item label="身份证" prop="IdCard">
                <el-input v-model="model.IdCard"></el-input>
            </el-form-item>
            </el-col>

            <el-col :span="8">
            <el-form-item label="学历" prop="Education">
                <el-input v-model="model.Education"></el-input>
            </el-form-item>
            </el-col>
            </el-row>


            <el-row>
            <el-col :span="8">
            <el-form-item label="毕业学校" prop="School">
                <el-input v-model="model.School"></el-input>
            </el-form-item>
            </el-col>

            <el-col :span="8">
            <el-form-item label="专业" prop="Major">
                <el-input v-model="model.Major"></el-input>
            </el-form-item>
            </el-col>

            <el-col :span="8">
            <el-form-item label="联系地址" prop="Address">
                <el-input v-model="model.Address"></el-input>
            </el-form-item>
            </el-col>
            </el-row>

            <el-row>
            <el-col :span="8">
            <el-form-item label="邮编" prop="ZipCode">
                <el-input v-model="model.ZipCode"></el-input>
            </el-form-item>
            </el-col>

            <el-col :span="8">
             <el-form-item label="手机号" prop="Phone">
                <el-input v-model="model.Phone"></el-input>
            </el-form-item>
            </el-col>

            <el-col :span="8">
             <el-form-item label="外语语种" prop="ForeignLanguage">
                <el-input v-model="model.ForeignLanguage"></el-input>
            </el-form-item>
            </el-col>
            </el-row>

            <el-row>
            <el-col :span="8">
             <el-form-item label="外语水平" prop="ForeignLanguageLevel">
                <el-input v-model="model.ForeignLanguageLevel"></el-input>
            </el-form-item>
            </el-col>

            <el-col :span="8">
             <el-form-item label="计算机水平" prop="ComputerLevel">
                <el-input v-model="model.ComputerLevel"></el-input>
            </el-form-item>
            </el-col>

            <el-col :span="8">
            <el-form-item label="毕业时间" prop="GraduationTime">
                <el-date-picker type="date" placeholder="选择日期" v-model="model.GraduationTime" style="width: 100%;"></el-date-picker>
            </el-form-item>
            </el-col>
            </el-row>

            <el-row>
            <el-col :span="8">
            <el-form-item label="到职时间" prop="ArrivalTime">
                <el-date-picker type="date" placeholder="选择日期" v-model="model.GraduationTime" style="width: 100%;"></el-date-picker>
            </el-form-item>
            </el-col>

            <el-col :span="8">
            <el-form-item label="职称" prop="PositionalTitles">
                <el-input v-model="model.PositionalTitles"></el-input>
            </el-form-item>
            </el-col>

            <el-col :span="8">
             <el-form-item label="教育经历" prop="EducationExperience">
                <el-input v-model="model.EducationExperience"></el-input>
            </el-form-item>
            </el-col>
            </el-row>

            <el-row>
            <el-col :span="8">
             <el-form-item label="工作经历" prop="WorkExperience">
                <el-input v-model="model.WorkExperience"></el-input>
            </el-form-item>
            </el-col>
            
            <el-col :span="8">
            <el-form-item label="邮箱" prop="Email">
                <el-input v-model="model.Email"></el-input>
            </el-form-item>
            </el-col>

            <el-col :span="8">
            <el-form-item label="部门" prop="DepartmentId">
                <el-select v-model="model.DepartmentId" placeholder="请选择产品部门">
                    <el-option v-for="item in DepartmentList" :key="item.Id" :label="item.Name"
                    :value="item.Id"></el-option>
                </el-select>
            </el-form-item>
            </el-col>
            </el-row>

            <el-row>

            <el-col :span="8">
            <el-form-item label="岗位" prop="SystemPostId">
                <el-select v-model="model.SystemPostId" placeholder="请选择岗位">
                    <el-option v-for="item in SystemPostList" :key="item.Id" :label="item.Name"
                    :value="item.Id"></el-option>
                </el-select>
            </el-form-item>
            </el-col>
 
            </el-row>
      
            <el-form-item>
                <el-button type="primary" @click="submitForm">{{ isUpdate?'立即保存':'立即创建' }}</el-button>
                <el-button @click="resetForm">重置</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>

<script>
export default {
    props: {
        model: {
            require: true,
            type: Object
        },
        isUpdate: {
            require: true,
            type: Boolean
        }
    },
    data() {
        return {
            ProProcessList:[],
            rules: {
                PersonCode : { required: true, message: '请输入员工编号', trigger: 'blur' },
                Name: { required: true, message: '请输入员工姓名', trigger: 'blur' },
                Phone:{required:true,message:'请输入手机号',trigger:'blur'},
                DepartmentId:{required:true,message:'请选择部门',trigger:'blur'},
                SystemPostId:{required:true,message:'请选择岗位',trigger:'blur'},
            },
            DepartmentList:[],
            SystemPostList:[]
        }
    },
    created(){
        this.getEmployeesAll();
        this.getSystemPostData();
        this. getDepartmentData();
    },  
    methods:{
        submitForm() {
            this.$refs['ruleForm'].validate((valid) => {
                if (valid) {

                    if(this.isUpdate){
                        this.put();
                    }
                    else{
                        this.add();
                    }

                } else {
                    this.showNotify('请输入必填项');
                    return false;
                }
            });
      },
      resetForm() {
        this.$refs['ruleForm'].resetFields();
      },
      add(){
        this.$http.postForm('/api/Employees',{model:this.model},{loading:this.$loading()})
        .then(res=>{
            this.$emit('callback');
        })

      },
      //修改
      put(){
        this.$http.putForm('/api/Employees',{model:this.model},{loading:this.$loading()})
		.then((res)=>{
            this.$emit('callback');
		})
      },

      getEmployeesAll(){
        this.$http.get('/api/Employees/GetAll')
        .then(res=>{
            this.ProProcessList=res.Data ;
        })
      },

      getDepartmentData(){
        this.$http.get('/api/Department/GetAll')
        .then(res=>{
            this.DepartmentList=res.Data;
        })
      },
      getSystemPostData(){
        this.$http.get('/api/SystemPost/GetAll')
        .then(res=>{
            this.SystemPostList=res.Data;
        })
      }
    }
}
</script>

<style></style>